<?php require_once 'header.php';?>    
<!-- DataTables Responsive CSS -->
    <link href="sb2/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet">
        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                        <?php echo XXF_BACK?>
                        评测对象管理 &nbsp;[<font color="red"><?php echo xdb::getInstance()->getvar("select pjname from pingjiao where id=$pjid")?></font>]
                        <br>新增评测对象：
                        <select name='x' id='cname'>
                        	<option value="0">请选择班级</option>
                        	<?php
                        	foreach ($stuclass as $row){
                        	    echo '<option value="'.$row['cname'].'">';
                        	    echo $row['cname'];
                                echo '</option>';
                        	}
                        	?>
                        </select>&nbsp;
                        <select name='x' id='tname'>
                        	<option value="0">请选择评测对象</option>
                        	<?php
                        	foreach ($stuteacher as $row){
                        	    echo '<option value="'.$row['tname'].'">';
                        	    echo $row['tname'];
                                echo '</option>';
                        	}
                        	?>
                        </select>&nbsp;
                        &nbsp;
                        <button onclick="pjoadd()">新增</button>
                        <input name="x" id="pjid" value="<?php echo $pjid?>" type="hidden">
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                        	<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                                <thead>
                                    <tr>
                                        <th>序号</th>
                                        <th>评测班级</th>
                                        <th>评测对象</th>
                                        <th>评测分数</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                	<?php
                                	$i=0;
                                	foreach ($result as $row){$i++;
                                	?>
                                    <tr class="<?php echo $i%2==0?"even":"odd";?> gradeA">
                                    	<td><?php echo $i;?></td>
                                        <td><?php echo $row['cname']?></td>
                                        <td><?php echo $row['tname']?></td>
                                        <td><?php echo round(xdb::getInstance()->getvar("SELECT AVG(fen) from pjresult where pjoid=".$row['id']),2)?></td>
                                        <td><a href="pingce/type/pingceresultshow/pjoid/<?php echo $row['id']?>">查看</a> 删除</td>
                                    </tr>
                                	<?php 
                                	}
                                	?>
                                </tbody>
                            </table>
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
             </div>
        </div>
        <!-- /#page-wrapper -->
  </div>
        <!-- DataTables JavaScript -->
<?php require_once 'bottom.php';?>
    <script src="sb2/vendor/datatables/js/jquery.dataTables.js"></script>
    <script src="sb2/vendor/datatables-plugins/dataTables.bootstrap.min.js"></script>
    <script src="sb2/vendor/datatables-responsive/dataTables.responsive.js"></script>
    <script>
    $(document).ready(function() {
        $('#dataTables-example').DataTable({
            responsive: true,
            "aaSorting": [[ 0, "asc" ]],
            "aLengthMenu": [ 100,50,25,10]
        });
    });
    function pjoadd(){
    	$cname=$("#cname").val();
    	$tname=$("#tname").val();
    	if($cname==0||$tname==0){
        	$.xalert("请将信息填写完整！");
        }else{
            $.xloading(1);
        	$.xtodb("add","pjobject",$("[name='x']"),"pjid_cname_tname",function(data){//增加数据，数据库，操作相关form，验证列不能重复，回调
        		if(data==0){
        			$.xloading(0);
        			$.xalert("添加失败");
        		}else if(data==1){
        			window.location.reload();
        		}else{
					console.log(data);
            	}
        	});
        }
    }
	</script>